using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

public class PlayerRollState : PlayerLandingState
{
    private PlayerRollData rollData;
    public PlayerRollState(PlayerMovementMachine stateMachine) : base(stateMachine)
    {
        rollData = stateMachine.Player.Data.PlayerGroundedData.RollData;
    }

#region IState Methods
    public override void Enter()
    {
        base.Enter();
        StateMachine.ReusableData.ShouldSprint = false;
        StateMachine.ReusableData.MovementSpeedModify = rollData.SpeedModifier;
        StartAnimation(StateMachine.Player.AnimationData.RollParameterHash);        
    }

    public override void PhysicUpdate()
    {
        base.PhysicUpdate();
        if(StateMachine.ReusableData.InputMovement == Vector2.zero)
        {
            return;
        }
        RotateTowardsTargetRotation();
    }

    public override void OnAnimationTransitionEvent()
    {
        base.OnAnimationTransitionEvent();
        if (StateMachine.ReusableData.InputMovement == Vector2.zero)
        {
            StateMachine.ChangeState(StateMachine.MediumStoppingState);
            return;
        }
        
        OnMove();
    }

    public override void Exit()
    {
        base.Exit();
        StopAnimation(StateMachine.Player.AnimationData.RollParameterHash);        
    }
#endregion

#region Input Methods
    protected override void OnJumpPerformed(InputAction.CallbackContext context)
    {
    }
#endregion
}
